#include <bits/stdc++.h>
using namespace std;

#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

typedef long long LL;

int t;
int n;
const int N = 1005;
int ans[N];

#define list _list

const int list[] = {
	4, 2, 5, 5, 4, 5, 6, 3, 7, 6
};

int main(int argc, char const *argv[])
{
	for (int i=1; i<=1000; ++i)
	{
		int x = i;
		int count = 0;
		while (x)
		{
			count += list[x % 10];
			x /= 10;
		}
		ans[count] = i;
	}

	int t;
	scanf("%d", &t);
	for (int kk=0; kk<t; ++kk)
	{
		scanf("%d", &n);
		if (n >= 4)
		{
			if (n % 2)
			{
				putchar('7');
				n -= 2;
			}
			for (int i=0; i<n/2; ++i) putchar('1');
			putchar('\n');
		} else printf("%d\n", ans[n]);
	}


	return 0;
}